package com.czwx.bee.base.common.dto;

import com.czwx.bee.base.common.exception.BizExceptionEnum;
import com.czwx.bee.base.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 服务器响应结果对象
 *
 * @author WIKI
 *
 * @param <T>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseDto<T> {
    /**
     * 服务器响应编号
     */
    private String code;
    /**
     * 服务器响应消息
     */
    private String mesg;
    /**
     * 服务器响应结果对象
     */
    private T data;

    public  ResponseDto(BizExceptionEnum bizExceptionEnum){
          this.code=bizExceptionEnum.getCode();
          this.mesg=bizExceptionEnum.getMessage();
    }

    public  ResponseDto(BusinessException businessException){
        this.code=businessException.getCode();
        this.mesg=businessException.getMessage();
    }

    public  ResponseDto(BizExceptionEnum bizExceptionEnum,T t){
        this.code=bizExceptionEnum.getCode();
        this.mesg=bizExceptionEnum.getMessage();
        this.data=t;
    }

    public  ResponseDto(String code,String mesg){
        this.code=code;
        this.mesg=mesg;
    }

    public void ChangeBizException(BizExceptionEnum bizExceptionEnum){
        this.code=bizExceptionEnum.getCode();
        this.mesg=bizExceptionEnum.getMessage();

    }
}
